import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { renderDict } from '#/utils/render';
import { getDictOptions } from '#/utils/dict';
export const querySchema: FormSchemaGetter = () => [

  {
    component: 'Input',
    fieldName: 'clientId',
    label: 'AI机器人',
  },

  {
    component: 'Input',
    fieldName: 'taskId',
    label: '任务ID',
  },
  {
    component: 'Input',
    fieldName: 'taskName',
    label: '任务名称',
  },

];

// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [
  { type: 'checkbox', width: 60 },
  {
    title: 'ID',
    field: 'id',
  },
  {
    title: '账号',
    field: 'account',
  },

  {
    title: '角色状态',
    field: 'status',
    formatter: ({ cellValue }) => {
      switch (cellValue) {
        case 1:
          return '正常';
        default:
          return '未知';
      }
    },
  },
  {
    title: '登录状态',
    field: 'loginStatus',
    formatter: ({ cellValue }) => {
      switch (cellValue) {
        case 1:
          return '已登录';
        default:
          return '未登录';
      }
    },
  },
  {
    title: '图片',
    field: 'runImg',
    slots: { default: 'runImg' },
  },
  {
    title: 'AI机器人',
    field: 'clientId',
  },
  {
    title: '自媒体平台',
    field: 'type',
    slots: {
      default: ({ row }) => {
        // 可选从DictEnum中获取 DictEnum.SYS_USER_SEX 便于维护
        return renderDict(row.type, 'sys_plat_type');
      },
    },
  },
  {
    title: '小红书uid',
    field: 'uid',
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    width: 210,
  },
];

export const modalSchema: FormSchemaGetter = () => [

  {
    label: '账号',
    fieldName: 'account',
    component: 'Input',
    rules: 'required',
  },

  {
    label: '平台',
    fieldName: 'type',
    component: 'Select',
    componentProps: {
      // 可选从DictEnum中获取 DictEnum.SYS_USER_SEX 便于维护
      options: getDictOptions('sys_plat_type'),
    },
    rules: 'selectRequired',
  },
  {
    label: '显示顺序',
    fieldName: 'sort',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '备注',
    fieldName: 'remark',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '小红书UID',
    fieldName: 'uid',
    component: 'Input',
    rules: 'required',
  },
];
